const regAPI = 'http://jx.xuzhixiang.top/ap/api/reg.php'
const checkusernameAPI = 'http://jx.xuzhixiang.top/ap/api/checkname.php'
const loginAPI = 'http://jx.xuzhixiang.top/ap/api/login.php'
const proudtListAPI = 'http://jx.xuzhixiang.top/ap/api/productlist.php'
const productAddAPI = 'http://jx.xuzhixiang.top/ap/api/goods/goods-add.php'
const productDeleteAPI = 'http://jx.xuzhixiang.top/ap/api/goods/goods-delete.php'


/* 修改商品 接口

接口地址：    http://jx.xuzhixiang.top/ap/api/goods/goods-update.php
     接口请求方式：get
     接口参数：

pid（必选）商品的id
pname（必选）商品
pprice（必选）商品
pdesc（必选）商品 
pimg（必选）商品 
*/

const productUpdateAPI = 'http://jx.xuzhixiang.top/ap/api/goods/goods-update.php'


/* 根据商品 id 获取商品详情接口

 接口地址：http://jx.xuzhixiang.top/ap/api/detail.php
接口请求方式：get
接口参数：
id  商品的id
使用方式
获取id为1的商品的详情
http://jx.xuzhixiang.top/ap/api/detail.php?id=1
服务器返回json数据 */
const CartListAPI = "http://jx.xuzhixiang.top/ap/api/cart-list.php"
const CarAddAPI = "http://jx.xuzhixiang.top/ap/api/add-product.php"
const productDetailAPI = 'http://jx.xuzhixiang.top/ap/api/detail.php'
const CartUpdateAPI = "http://jx.xuzhixiang.top/ap/api/cart-update-num.php"
const CartDeleteAPI = "http://jx.xuzhixiang.top/ap/api/cart-delete.php"
/*  let num = 0;
          let singleIpts = document.querySelectorAll(".single-ipt");
          console.log(singleIpts);
          let arr = [...singleIpts];
          let resArr = arr.filter((v = v.checked == true));
          resArr.forEach((singleIpt) => {
            let li = singleIpt.parentNode;
            let p = document.querySelector(".pprice-p");
            let pnumIpt = document.querySelector(".pnum-ipt");
            let count = p.innerHTML * pnumIpt;
            num = num + count;
          }); */
/* function counFN() {
     let fuxuan = document.querySelectorAll(".fuxuan");
     let arr = [...fuxuan]; //利用三点la运算符把伪数组转成真数组
     let resArr = arr.filter((str) => str.checked == true); //用filter方法对数组过滤，过滤出已经选中的单选框
     // console.log(resArr);
     //遍历整个复选框
     let num = 0;
     resArr.forEach((fuxuan) => {
          // console.log(fuxuan);
          let li = fuxuan.parentNode;
          // console.log(li);
          let price = li.querySelector(".price span");
          // console.log(price);
          let pnum = li.querySelector(".pnum-ipt");
          // console.log(pnum);
          let count = price.innerHTML * pnum.value;
          num = num + count;
     });
     let ospan = document.querySelector(".num-span");
     let ozj = document.querySelector(".num-zj");
     let tanchu = document.querySelector("#tanchu-box p span"); //弹出框计算的总价
     ospan.innerHTML = num;
     ozj.innerHTML = num;
     tanchu.innerHTML = num;
} */
/* function fuxuan() {
     let fuxuan = document.querySelectorAll(".fuxuan");
     let arr = [...fuxuan]; //利用三点la运算符把伪数组转成真数组
     let flag = arr.every((v) => v.checked == true);
     let quanxuan = document.querySelector(".quanxuan");
     quanxuan.checked = flag;
     counFN();
   } */